home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / graphics / jclplasm.arj / GENPLAS.C next >
Text File  |  1994-02-04  |  2KB  |  84 lines

  1. /*
  2.  
  3.     JCL-Plasma v1.3a (C) 1994 JCL-software
  4.  
  5.     This file contains the routines necessary to create the PLASMA.DAT
  6.     file required by JCLPLASM.ASM.  These routines are provided separately
  7.     to ease modification.  Feel free to tweak the values here (thats all
  8.     I did to get a good effect) - send me any good variations you might
  9.     create...  [compiled with TurboC, BTW]
  10.  
  11.     WARNING - if you don't have a coprocessor this takes AGES....
  12.  
  13.     See README.TXT for more info
  14.  
  15.     Jezza (jcl1008@cus.cam.ac.uk)
  16.  
  17. */
  18.  
  19.  
  20. #include <stdio.h>
  21. #include <math.h>
  22.  
  23. void    main()
  24. {
  25.     float    x,y,count,i;
  26.     int    lead,offset;
  27.     FILE    *fp;
  28.     unsigned char value;
  29.  
  30.     printf("\nJCL-plasma Generator 1.1L (C) JCL-Software 1994\n\nHang in there ...!\n");
  31.  
  32.     if (!(fp=fopen("PLASMA.DAT","wb")))
  33.     {
  34.         printf("\7Cant open output file PLASMA.DAT\n");
  35.         exit(255);
  36.     }
  37.  
  38.     /* First generate the plasma map.  This is effectively just an
  39.        arbitrary function of x and y which gives a smooth but
  40.        non-uniform surface */
  41.  
  42.  
  43.     for (y=0;y<300;y++)
  44.     for (x=0;x<512;x++)
  45.     {
  46.         value=64+10*( sin(x/30) + cos(y/46) +
  47.                   cos(x/37) + sin(y/70) +
  48.                   sin((x+y)/43) +
  49.                   cos(hypot(256-x,150-y)/20)
  50.                   );
  51.         fputc(value,fp);
  52.     }
  53.  
  54.     /* Then arbitrary movement for two pointers */
  55.  
  56.     for (count=0;count<10000;count++)
  57.     {
  58.         lead=           96+92*cos(count/32)
  59.              +512*(int)(48+47*sin(count/16));
  60.         offset=         96+92*sin(count/21)
  61.              +512*(int)(48+47*cos(count/24))
  62.              -lead;
  63.         fwrite(&lead,2,1,fp);
  64.         fwrite(&offset,2,1,fp);
  65.     }
  66.  
  67.     /* And a smooth transition colour lookup table */
  68.  
  69.     for (i=-256; i<256*39; i++)
  70.         if (i<0)
  71.         {
  72.             fputc(0,fp);
  73.             fputc(0,fp);
  74.             fputc(0,fp);
  75.         }
  76.         else
  77.         {
  78.             fputc((sin(i/20)*sin(i/15)*31+31),fp);
  79.             fputc((sin(i/35)*sin(i/22)*31+31),fp);
  80.             fputc((sin(i/13)*sin(i/30)*31+31),fp);
  81.         }
  82.     fclose(fp);
  83. }
  84.